package com.magenta.maxoptra.gis.distancematrix.commands;

import com.magenta.maxoptra.gis.distancematrix.*;

import java.util.Set;

/**
 * @author Sergey Grachev
 */
final class EventsSubscribe implements Command {

    private final String queueName;
    private final Set<EventType> events;

    EventsSubscribe(final String queueName, final Set<EventType> events) {
        this.queueName = queueName;
        this.events = events;
    }

    @Override
    public CommandType getType() {
        return CommandType.EVENTS_SUBSCRIBE;
    }

    @Override
    public UpdateRequestType isRequireMatrixUpdating() {
        return UpdateRequestType.NONE;
    }

    @Override
    public void execute(final DistanceMatrixDAO db, final DistanceMatrixServiceProxy service) {
        service.subscribe(queueName, events);
    }

    @Override
    public String toString() {
        return "EventsSubscribe{" +
                "queueName='" + queueName + '\'' +
                ", events=" + events +
                '}';
    }
}
